import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { User } from "./user.entity";
@Injectable()
export class UsersService {
  constructor(@InjectRepository(User) private repo: Repository<User>) {}
  findById(id: string) {
    return this.repo.findOne({ where: { id } });
  }
  findByUsername(username: string) {
    return this.repo.findOne({ where: { username } });
  }
  create(data: Partial<User>) {
    const u = this.repo.create(data as any);
    return this.repo.save(u);
  }
}
